{ INFORMATICS.MCCME.RU
  Problem statement: http://informatics.mccme.ru/moodle/mod/statements/view3.php?chapterid=364
  Verdict: Accepted
}
uses SysUtils, Math;
 
var
	i,j,n,m,cur,kk,p,pp:longint;
	a:array[0..1010,0..1010] of int64;
 
begin
reset(input,'input.txt');
rewrite(output,'output.txt');
read(n,m);
kk:=n*m;
cur:=1;
a[1][1]:=0;
i:=1;
j:=2;
p:=2;
if m=1 then begin
	for i:=2 to n do begin
		a[i][1]:=cur;
		inc(cur);
	end;
end;
while cur<kk do begin 
	p:=j;
	pp:=i;
	while (i<=n) and (j>0) do begin
		a[i][j]:=cur;
		inc(cur);
		dec(j);
		inc(i);
	end;
	i:=pp;
	j:=p+1;
	if j>m then begin
		inc(i);
		j:=m;
	end;
end;
for i:=1 to n do begin
	for j:=1 to m do
		write(a[i][j],' ');
	writeln;
end;
end.